package com.smdp.controller;


import com.smdp.dto.Result;
import com.smdp.service.IVoucherScheduleService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 预约秒杀券前端控制器。
 * 包含预约秒杀券的功能。
 *
 * @author 蔡方珩
 */
@RestController
@RequestMapping("/schedule")
public class VoucherScheduleController {

    @Resource
    private IVoucherScheduleService voucherScheduleService;

    /**
     * 预约秒杀券
     * @param voucherId 秒杀券id
     * @return 成功：优惠券id / 失败：失败原因
     */
    @PostMapping("/book/seckill/{id}")
    public Result scheduleSeckillVoucher(@PathVariable("id") Long voucherId) {
        return voucherScheduleService.scheduleSeckillVoucher(voucherId);
    }
}
